package com.school.graduation.goods.presenter;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.school.graduation.R;
import com.school.graduation.bean.FindResultBean;
import com.school.graduation.bean.GoodsBean;
import com.school.graduation.detailed.view.DetailedActivityNew;

import java.util.List;

public class FoundGoodDetailAdapterNew extends RecyclerView.Adapter<HotMarketViewHolder> {
    private List<GoodsBean> detailHots;
    private Context context;

    public FoundGoodDetailAdapterNew(List<GoodsBean> detailHots) {
        this.detailHots = detailHots;
    }

    @Override
    public HotMarketViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        context = parent.getContext();
        return new HotMarketViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_hot_detail_recycler_new,parent,false));
    }

    @Override
    public void onBindViewHolder(HotMarketViewHolder holder, final int position) {
        RelativeLayout item = holder.getView(R.id.hot_market_detail_item_new);
        ImageView img = holder.getView(R.id.hot_detail_item_img_new);
        TextView content = holder.getView(R.id.hot_detail_item_content_new);
        TextView price = holder.getView(R.id.hot_detail_item_price_new);

        Glide.with(context).load(detailHots.get(position).getImg()).into(img);
        content.setText(detailHots.get(position).getDetail());
        price.setText(detailHots.get(position).getPrice()+"");

        item.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putString("item",detailHots.get(position).get_id());
                DetailedActivityNew.jumpToDetail(context,bundle);
            }
        });
    }

    @Override
    public int getItemCount() {
        return detailHots.size();
    }
}
